/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cassys.ejb.sessionbean;

import cassys.dataaccess.DAOFactory;
import cassys.dataaccess.PeerAssessmentDAO;
import cassys.datatransferobjects.PeerAssessmentDTO;
import cassys.datatransferobjects.PeerAssessmentEvaluationDTO;
import java.util.ArrayList;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;

/**
 *
 * @author Priyanka
 */
@Stateless(mappedName="PeerAssessmentBean")  
public class PeerAssessmentBean implements PeerAssessmentBeanRemote{
    
      
    public PeerAssessmentDAO dao=null;
    
    public void ejbCreate() {
       dao = DAOFactory.getInstance().getPeerAssessmentDAO();
    }

    public void insertPA(PeerAssessmentDTO dto)
    {
      dao.insertPeerAssessment(dto);
    }
    
     public void updatePA(PeerAssessmentDTO dto)
    {
      dao.updatePeerAssessment(dto);
    }
     
    public void deletePA(PeerAssessmentDTO dto)
    {
      dao.deletePeerAssessment(dto);
    }
    
    public PeerAssessmentDTO findPA(String paId) {
        return dao.findPeerAssessment(paId);
    } 
    
     
    public ArrayList<PeerAssessmentEvaluationDTO> findALLPAEvalution() {
        
          ArrayList<PeerAssessmentEvaluationDTO> modules = null;
        PeerAssessmentEvaluationDTO[] modArray = null;
     
        modArray = dao.findALLPeerAssessmentEvalution();
        
        if(modArray.length > 0){
            modules = new ArrayList<PeerAssessmentEvaluationDTO>(modArray.length);
            for(int i = 0; i < modArray.length; i++)
                modules.add(i, modArray[i]);
        }
   
        return modules;
    }
    
   public ArrayList<PeerAssessmentEvaluationDTO> findPeerAssessmentEvalutionForAPA(String paID){
       
         ArrayList<PeerAssessmentEvaluationDTO> modules = null;
        PeerAssessmentEvaluationDTO[] modArray = null;
     
        modArray = dao.findPeerAssessmentEvalutionForAPA(paID);
        
        if(modArray.length > 0){
            modules = new ArrayList<PeerAssessmentEvaluationDTO>(modArray.length);
            for(int i = 0; i < modArray.length; i++)
                modules.add(i, modArray[i]);
        }
      
        return modules;
       
   
   }

    @Override
    public PeerAssessmentDTO findPAByModule(String moduleCode) {
         return dao.findPeerAssessmentByModule(moduleCode);
    }
     
    
}
